<template>
  <div class="ma-content-block lg:flex justify-between p-4">
    <!-- CRUD 组件 -->
    <ma-crud :options="options" :columns="columns" ref="crudRef">
    </ma-crud>
  </div>
</template>
<script setup>
import { ref, reactive } from 'vue'
import infoRecruitment from '@/api/info/infoRecruitment'
import { Message } from '@arco-design/web-vue'
import tool from '@/utils/tool'
import * as common from '@/utils/common'

const crudRef = ref()


const numberOperation = (newValue, id, numberName) => {
  infoRecruitment.numberOperation({ id, numberName, numberValue: newValue }).then( res => {
    res.success && Message.success(res.message)
  }).catch( e => { console.log(e) } )
}

const switchStatus = (statusValue, id, statusName) => {
  infoRecruitment.changeStatus({ id, statusName, statusValue }).then( res => {
    res.success && Message.success(res.message)
  }).catch( e => { console.log(e) } )
}


const options = reactive({
  id: 'info_recruitment',
  rowSelection: {
    showCheckedAll: true
  },
  pk: 'id',
  operationColumn: true,
  operationColumnWidth: 160,
  formOption: {
    viewType: 'modal',
    width: 600
  },
  api: infoRecruitment.getList,
  recycleApi: infoRecruitment.getRecycleList,
  add: {
    show: true,
    api: infoRecruitment.save,
    auth: ['info:recruitment:save']
  },
  edit: {
    show: true,
    api: infoRecruitment.update,
    auth: ['info:recruitment:update']
  },
  delete: {
    show: true,
    api: infoRecruitment.deletes,
    auth: ['info:recruitment:delete'],
    realApi: infoRecruitment.realDeletes,
    realAuth: ['info:recruitment:realDeletes']
  },
  recovery: {
    show: true,
    api: infoRecruitment.recoverys,
    auth: ['info:recruitment:recovery']
  }
})

const columns = reactive([
  {
    title: "ID",
    dataIndex: "id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    commonRules: {
      required: true,
      message: "请输入ID"
    }
  },
  {
    title: "职位名称",
    dataIndex: "name",
    formType: "input",
    search: true
  },
  {
    title: "要求",
    dataIndex: "ask_require",
    formType: "input"
  },
  {
    title: "薪资待遇",
    dataIndex: "salary_benefits",
    formType: "input"
  },
  {
    title: "上班地址",
    dataIndex: "addr",
    formType: "input"
  },
  {
    title: "排序",
    dataIndex: "display_order",
    formType: "input-number",
    min:1,
    precision: 0,

  },
  {
    title: "备注",
    dataIndex: "remark",
    formType: "textarea",
    hide: true
  },
  {
    title: "状态",
    dataIndex: "status",
    formType: "radio",
    search: true,
    dict: {
      name: "data_status",
      props: {
        label: "title",
        value: "key"
      },
      translation: true
    },
    addDefaultValue: '1',
  },
  {
    title: "创建时间",
    dataIndex: "create_time",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  }
])
</script>
<script> export default { name: 'info:recruitment' } </script>